package main
import (
	"fmt"
	// "slices"
)

func main(){
	var s[]string
	fmt.Println("uninit:",s,s==nil,len(s)==0)

	s = make([]string, 3)
	fmt.Println("emp:",s,"len:",len(s),"cap:",cap(s))

	s[0] = "1"
	s[1] = "2"
	s[2] = "3"
	fmt.Println("s:",s)
	fmt.Println("s[1]:",s[1])

	s = append(s,"4")
	s = append(s,"5","6")
	s2 := append(s,"7")
	fmt.Println("s:",s,"s2:",s2)
	fmt.Println("lenth s:",len(s),"s2:",len(s2))

	// 深拷贝：创建新的底层数组
	// c :=make([]string,len(s))
	// copy(c,s)
	// 浅拷贝：本质是引用赋值
	c := s
	s[1] = "hahaha"
	fmt.Println("c:",c)

	// 2、3、4
	l := s[2:5]
	fmt.Println("l:",l)

	// 0、1、2、3、4、5
	l = s[:6]
	fmt.Println("l:",l)

	// 3、4、5
	l = s[3:]
	fmt.Println("l:",l)

	// 原则：前到后不到

	t := []string{"hahaha","hwhwhw","huhuhu"}
	fmt.Println("t:",t)

	twoD := make([][]int,3)
	for i := 0; i < 3; i++ {
		innerLen := i+1
		twoD[i] = make([]int, innerLen)
		for j := 0; j < innerLen; j++ {
			twoD[i][j] = i + j
		}
	}
	fmt.Println("twoD:",twoD)
	
}